package com.wench.design.pattern.iterator;

import java.util.List;

/**
 * 具体迭代器角色类
 *
 * @author wench
 */
public class StudentIteratorImpl implements StudentIterator {

    private List<Student> list;

    /**
     * 用来记录遍历时的位置
     */
    private int position = 0;

    public StudentIteratorImpl(List<Student> list) {
        this.list = list;
    }

    @Override
    public boolean hashNext() {
        return position < list.size();
    }

    @Override
    public Student next() {
        return list.get(position++);
    }
}
